//
// Created by PanCheng on 15/05/2017.
//

#ifndef SDK_PROJ_UTILS_H
#define SDK_PROJ_UTILS_H

#include "YTFaceTrackPro.h"
#include "FaceTrackDefine.h"
#include <sys/system_properties.h>
// yuv420sp to rgb
#include "yuv420sp_to_rgb_fast_asm.h"
// rotate
#include "transform_by_orientation_tag.h"


static void rgba2rgb(const cv::Mat& rgba, cv::Mat& rgb)
{
//     cv::cvtColor(mat, rgba, CV_RGB2BGRA);

    rgb.create(rgba.rows, rgba.cols, CV_8UC3);
    {
        const unsigned char* ptr = (const unsigned char*)rgba.data;
        unsigned char* rgbptr = (unsigned char*)rgb.data;
        int size = rgba.cols * rgba.rows;
        for (int i=0; i<size; i++)
        {
            rgbptr[0] = ptr[0];
            rgbptr[1] = ptr[1];
            rgbptr[2] = ptr[2];

            ptr += 4;
            rgbptr += 3;
        }
    }
}

static std::string get_device_model_name()
{
    std::string name;

    char mod[PROP_VALUE_MAX + 1];
    int lmod = __system_property_get("ro.product.model", mod);
    if (lmod > 0)
    {
        name = std::string(mod);
    }
    else
    {
        // use manufacturer as fallback
        char man[PROP_VALUE_MAX + 1];
        int lman = __system_property_get("ro.product.manufacturer", man);
        if (lman > 0)
        {
            name = std::string(man);
        }
    }

    return name;
}





#endif //SDK_PROJ_UTILS_H
